home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsdemos / egsexamples / other / star.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-06  |  2.0 KB  |  102 lines

  1. /* star.c
  2. **
  3. ** FM - 12.08.92
  4. **
  5. ** Display a Star with a colorflow.
  6. **
  7. **
  8. ** (c) by VIONA-Development 1992/93
  9. **
  10. */
  11.  
  12. #include <exec/types.h>
  13. #include <proto/exec.h>
  14. #include <egs/egsintui.h>
  15. #include <egs/proto/egsintui.h>
  16. #include <egs/egsgfx.h>
  17. #include <egs/proto/egsgfx.h>
  18. #include <egs/egs.h>
  19. #include <egs/proto/egs.h>
  20.  
  21.  
  22. /* die Zeiger auf unsere Libraries */
  23. struct Library *EGSIntuiBase;
  24. struct Library *EGSGfxBase;
  25. struct Library *EGSBase;
  26.  
  27.  
  28. /* Ausgabe eines regelmäßigen Sterns mit 4 Spitzen */
  29. void drawStar8( EG_RastPortPtr rp, long mx, long my, long h1, long h2 )
  30. {
  31.     EG_AreaMove( rp, mx,    my-h1 );
  32.     EG_AreaDraw( rp, mx+h2, my-h2 );
  33.     EG_AreaDraw( rp, mx+h1, my    );
  34.     EG_AreaDraw( rp, mx+h2, my+h2 );
  35.     EG_AreaDraw( rp, mx,    my+h1 );
  36.     EG_AreaDraw( rp, mx-h2, my+h2 );
  37.     EG_AreaDraw( rp, mx-h1, my );
  38.     EG_AreaDraw( rp, mx-h2, my-h2 );
  39.     EG_AreaEnd( rp );
  40. }
  41.  
  42.  
  43. /* und hier passiert etwas */
  44. #define MAX_SIZE        100
  45.  
  46. void doThings( EI_WindowPtr window )
  47. {
  48.     long size;
  49.  
  50.     for( size=MAX_SIZE; size>1; size-- )
  51.         {
  52.         EG_SetAPen( window->RPort, ((255*size)/MAX_SIZE)*0x1010000 + 0x0000ff00 );
  53.         drawStar8( window->RPort, window->Width/2,window->Height/2, MAX_SIZE,size );
  54.         }
  55.     WaitPort( window->UserPort );
  56. }
  57.  
  58.  
  59. /* das Hauptprogramm */
  60. void main( int argc, char *argv[] )
  61. {
  62.     static struct EI_NewWindow newWindow =
  63.         {
  64.         50,30, 400,300,
  65.         0,0, 0,0,
  66.         NULL,
  67.         EI_WINDOWCLOSE | EI_WINDOWBACK | EI_WINDOWDRAG,
  68.         NULL,
  69.         "Testfenster",
  70.         EI_SMART_REFRESH,
  71.         EI_iCLOSEWINDOW,
  72.         NULL,
  73.         {0,0,0,0,0,0,0},
  74.         NULL,
  75.         NULL
  76.         };
  77.     EI_WindowPtr window;
  78.  
  79.     /* die Libraries öffnen */
  80.     EGSIntuiBase = OpenLibrary( (UBYTE *)"egsintui.library", 0 );
  81.     if ( EGSIntuiBase )
  82.         {
  83.         EGSGfxBase = OpenLibrary( (UBYTE *)"egsgfx.library", 0 );
  84.         if ( EGSGfxBase )
  85.             {
  86.             EGSBase = OpenLibrary( (UBYTE *)"egs.library", 0 );
  87.             if ( EGSBase )
  88.                 {
  89.             window = EI_OpenWindow( &newWindow );
  90.             if ( window )
  91.                 {
  92.                 doThings( window );
  93.                 EI_CloseWindow( window );
  94.                 }
  95.                 CloseLibrary( EGSBase );
  96.                 }
  97.         CloseLibrary( EGSGfxBase );
  98.         }
  99.         CloseLibrary( EGSIntuiBase );
  100.         }
  101. }
  102.